#include <stdio.h>
#include <stdlib.h>

int main()
{
	int ***data = malloc(sizeof(int**)*28);
	int PageOutDegree[247428];
	int OutDegreeRank[300];
	int i,j,k,a,b,c,t = 0;
	FILE *fr,*fw;
	for(i = 0;i < 30;i++)
	{
		data[i] = malloc(sizeof(int *)*50);
		for(j = 0;j < 50;j++)
		{
			data[i][j] = malloc(sizeof(int)*900);
			for(k = 0;k < 900;k++)
				data[i][j][k] = 0;
		}
	}
	for(i = 0;i < 247428;i++)
		PageOutDegree[i] = -1;
	for(i = 0;i < 300;i++)
		OutDegreeRank[i] = 0;
	fr = fopen("wt2g_inlinks","r");
	while (fscanf(fr,"WT%d-B%d-%d ",&a,&b,&c) != EOF)
	{
		if(data[a][b][c] == 0)
		{
			data[a][b][c] = t;
			t++;
		}
	}
	fclose(fr);
	fr = fopen("wt2g_inlinks","r");
	while (fscanf(fr,"WT%d-B%d-%d ",&a,&b,&c) != EOF)
		PageOutDegree[data[a][b][c]]++;
	for(i = 0;i < 247428;i++)
		OutDegreeRank[PageOutDegree[i]]++;
	fclose(fr);
	fw = fopen("../res/Out_Degree_Result","w");
	for(i = 0;i < 300;i++)
		fprintf(fw,"%d\n",OutDegreeRank[i]);
	fclose(fw);
	exit(0);
	return 0;
}
